package com.example.skyline.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.skyline.common.PageCommon;
import com.example.skyline.entity.Log;
import com.example.skyline.entity.LogQuery;
import com.example.skyline.mapper.LogMapper;
import com.example.skyline.service.ILogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author git
 * @since 2025-05-16
 */
@Service
public class LogServiceImpl extends ServiceImpl<LogMapper, Log> implements ILogService {

    @Override
    @Async
    public void insert(Log operationLog) {
        super.save(operationLog);
    }

    @Override
    public PageCommon<Log> getList(Integer pageNum, Integer pageSize) {
        Page<Log> page = Page.of(pageNum, pageSize);
        page.addOrder(OrderItem.desc("operate_time"));
        Page<Log> page1 = lambdaQuery().page(page);
        return new PageCommon<>(page1.getPages(),page1.getTotal(), page1.getRecords());
    }
}
